<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include2923 :: header('工程概算台账列表(可研)')"/>
</head>
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
<!--                <label class="layui-form-label">工程名称</label>-->
<!--                <div class="layui-input-inline">-->
<!--                    <input type="text" name="proname" placeholder="" class="layui-input">-->
<!--                </div>-->
                <label class="layui-form-label">工程编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="pronum" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">工程类别</label>
                <div class="layui-input-inline">
                    <select name="type" lay-filter="aihao">
                        <option value=""></option>
                        <option value="1">基建类</option>
                        <option value="2">业扩类</option>
                        <option value="3">技改类</option>
                        <option value="4">大修类</option>
                    </select>
                </div>
                <label class="layui-form-label">起始日期</label>
                <div class="layui-input-inline">
                    <input type="text" id="startDate" name="startDate" class="layui-input" placeholder="请选择起始日期">
                </div>
                <label class="layui-form-label">结束日期</label>
                <div class="layui-input-inline">
                    <input type="text" id="endDate" name="endDate" class="layui-input" placeholder="请选择结束日期">
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit
                        lay-filter="infoAnalysis-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="infoAnalysis-table" lay-filter="infoAnalysis-table"></table>
    </div>
</div>
</body>

<script type="text/html" id="infoAnalysis-toolbar">
    <!--    <button class="pear-btn pear-btn-warming pear-btn-md"-->
    <!--            id="uploadFile">-->
    <!--        <i class="layui-icon layui-icon-add-1"></i>-->
    <!--        基建类工程导入-->
    <!--    </button>-->
</script>

<script type="text/html" id="infoAnalysis-bar">
    <!--    <button class="pear-btn pear-btn-md pear-btn-warming"-->
    <!--            lay-filter="export" lay-submit type="button">-->
    <!--        <i class="layui-icon layui-icon-export"></i>-->
    <!--        导出-->
    <!--    </button>-->
    <button class="pear-btn pear-btn-md pear-btn-warming"
            lay-event="viewdtl" type="button">
        <i class="layui-icon layui-icon-export"></i>
        明细详情
    </button>
    <button class="pear-btn pear-btn-md pear-btn-warming"
            lay-event="export" type="button">
        <i class="layui-icon layui-icon-export"></i>
        详情导出
    </button>
    <!--    <button shiro:hasPermission="info:infoAnalysis:edit" class="pear-btn pear-btn-warming pear-btn-sm"-->
    <!--            lay-event="edit" title="修改"><i class="layui-icon layui-icon-edit"></i>-->
    <!--    </button>-->

    <!--    <button shiro:hasPermission="info:infoAnalysis:remove" class="pear-btn pear-btn-danger pear-btn-sm"-->
    <!--            lay-event="remove" title="删除"><i class="layui-icon layui-icon-delete"></i>-->
    <!--    </button>-->
</script>

<script type="text/html" id="infoAnalysisfile-bar">
</script>

<script type="text/html" id="infoAnalysis-type">
    {{#if (d.dataState == '0') { }}
    <span class="layui-badge layui-bg-orange">开启</span>
    {{# }else if(d.dataState == '-1'){ }}
    <span class="layui-badge layui-bg-blue">关闭</span>
    {{# } }}
</script>

<th:block th:include="include2923 :: footer"/>
<script>
    layui.use(['table', 'form', 'jquery', 'upload'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var upload = layui.upload;
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素
            ,type: 'date'
        })

        //执行一个laydate实例
        laydate.render({
            elem: '#endDate' //指定元素
            ,type: 'date'
        })


        var MODULE_PATH = rootPath + "/InfoProjectbudgetController/";
        var MODULE_PATH_FILE = rootPath + "/InfoFileController/";

        var cols = [
            [
                {type: 'checkbox', fixed: 'left'},

                // {title: 'ID', field: 'id', align: 'center'},

                {title: '工程编码', field: 'pronum', align: 'center', width: 200, fixed: 'left'},

                {title: '工程名称', field: 'proname', align: 'center', width: 450, fixed: 'left'},

                {
                    title: '工程类别', field: 'type', align: 'center', width: 150, templet: function (res) {
                        if (res.type == '1') {
                            return '基建类';
                        } else if (res.type == '2') {
                            return '业扩类';
                        } else if (res.type == '3') {
                            return '技改类';
                        } else if (res.type == '4') {
                            return '大修类';
                        } else {
                            return '';
                        }
                    }
                },

                {title: '概算书日期', field: 'bookdate', align: 'center', width: 150},

                {title: '批次', field: 'batchnum', align: 'center', width: 200},

                {title: '可研工程总投资', field: 'total', align: 'center', width: 200},

                // {title: '可研与初设差额', field: 'kyandcscha', align: 'center', width: 200},
                {
                    title: '可研与初设差额', field: 'kyandcscha', align: 'center', width: 200, templet: function (res) {
                        if (res.kyandcscha == '0') {
                            return '0';
                        } else if (!res.kyandcscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.kyandcscha+'</a></div>';
                        }
                    }
                },

                {title: '初设工程总投资', field: 'totalcs', align: 'center', width: 200},

                // {title: '初设与结算差额', field: 'csandjscha', align: 'center', width: 200},

                {
                    title: '初设与结算差额', field: 'csandjscha', align: 'center', width: 200, templet: function (res) {
                        if (res.csandjscha == '0') {
                            return '0';
                        } else if (!res.csandjscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.csandjscha+'</a></div>';
                        }
                    }
                },

                {title: '结算工程总投资', field: 'totaljs', align: 'center', width: 200},

                // {title: '可研与结算差额', field: 'kyandjscha', align: 'center', width: 200},

                {
                    title: '可研与结算差额', field: 'kyandjscha', align: 'center', width: 200, templet: function (res) {
                        if (res.kyandjscha == '0') {
                            return '0';
                        } else if (!res.kyandjscha) {
                            return '/';
                        } else {
                            return '<div style="background-color:#ff7777; width: 100%; height: 100%;"><a class=""style="color:#fff">'+res.kyandjscha+'</a></div>';
                        }
                    }
                },

                {title: '操作', toolbar: '#infoAnalysis-bar', align: 'center', width: 300, fixed: 'right'}
            ]
        ]

        //table表单列表
        table.render({
            elem: '#infoAnalysis-table',
            url: MODULE_PATH + 'listana',
            page: true,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#infoAnalysis-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }],
            limit: 50,
            height: 700
        });

        //table图标事件绑定
        table.on('tool(infoAnalysis-table)', function (obj) {
            if (obj.event === 'remove') {
                window.remove(obj);
            } else if (obj.event === 'edit') {
                window.edit(obj);
            } else if (obj.event === 'export') {
                window.export(obj);
            } else if (obj.event === 'viewdtl') {
                window.viewdtl(obj);
            }
        });

        //table工具栏绑定
        table.on('toolbar(infoAnalysis-table)', function (obj) {
            if (obj.event === 'add') {
                window.add();
            } else if (obj.event === 'refresh') {
                window.refresh();
            }
        });

        //查询按钮绑定
        form.on('submit(infoAnalysis-query)', function (data) {
            table.reload('infoAnalysis-table', {where: data.field})
            return false;
        });

        //刷新按钮
        window.refresh = function () {
            table.reload('infoAnalysis-table');
        }

        window.export = function (obj) {
            var now = getnow();
            // console.log(data)
            var url = rootPath + '/AgencyStyleExportController/agencyStyleExport4anaSingle?id=' + obj.data['id']
            downloadFile(url, obj.data['pronum'] + "--综合分析比对" + now + ".xls");
        }
        // //导出
        // form.on('submit(export)', function (data) {
        //     var now = getnow();
        //     console.log(data)
        //     var url = rootPath + '/AgencyStyleExportController/agencyStyleExport4anaSingle?id=' + data.id
        //     downloadFile(url, "可研环节工程概算导入(未入库)台账" + now + ".xls");
        // });

        window.viewdtl = function (obj) {
            layer.open({
                type: 2,
                title: obj.data['proname'] + '综合比对详情',
                area: ['80%', '80%'],
                shade: 0.5,
                content: MODULE_PATH + 'viewdtl/' + obj.data['id']
            });
        }

        function getnow() {
            var myDate = new Date();	//创建Date对象
            var Y = myDate.getFullYear();   //获取当前完整年份
            var M = myDate.getMonth() + 1;  //获取当前月份
            var D = myDate.getDate();   //获取当前日1-31
            var H = myDate.getHours();  //获取当前小时
            var i = myDate.getMinutes();    //获取当前分钟
            var s = myDate.getSeconds();    //获取当前秒数
            // 月份不足10补0
            if (M < 10) {
                M = '0' + M;
            }
            // 日不足10补0
            if (D < 10) {
                D = '0' + D;
            }
            // 小时不足10补0
            if (H < 10) {
                H = '0' + H;
            }
            // 分钟不足10补0
            if (i < 10) {
                i = '0' + i;
            }
            // 秒数不足10补0
            if (s < 10) {
                s = '0' + s;
            }
            // 拼接日期分隔符根据自己的需要来修改
            var nowDate = M + '月' + D + '日 ' + H + '时' + i + '分' + s + '秒';
            return nowDate;
        }
    })


</script>
</html>